package com.zmn.oms.services.impl.conf.ordertag;

import com.zmn.common.utils.date.DateUtil;
import com.zmn.oms.model.entity.conf.checkout.ConfCheckout;
import com.zmn.oms.model.entity.conf.checkout.ConfCheckoutQuery;
import com.zmn.oms.model.entity.conf.ordertag.ConfOrderTag;
import com.zmn.oms.model.entity.conf.ordertag.ConfOrderTagQuery;
import com.zmn.oms.persistence.interfaces.conf.ordertag.ConfOrderTagDao;
import com.zmn.oms.services.interfaces.conf.ordertag.ConfOrderTagService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 类描述：
 *
 * @author liuying
 * @date 2021/05/06 17:03
 */
@Service
public class ConfOrderTagServiceImpl implements ConfOrderTagService {

    @Resource
    private ConfOrderTagDao confOrderTagDao;

    @Override
    public List<ConfOrderTag> listByQuery(ConfOrderTagQuery query) {
        List<ConfOrderTag> confList = confOrderTagDao.listByQuery(query);
        return confList;
    }

    @Override
    public List<ConfOrderTag> listPageByQuery(ConfOrderTagQuery query) {
        query.setTotalCount(confOrderTagDao.countByQuery(query));
        List<ConfOrderTag> confList = confOrderTagDao.listPageByQuery(query);
        return confList;
    }

    @Override
    public int countByQuery(ConfOrderTagQuery query) {
        return confOrderTagDao.countByQuery(query);
    }

    @Override
    public ConfOrderTag findConfById(Integer id) {
        return confOrderTagDao.selectByPrimaryKey(id);
    }

    @Override
    public List<ConfOrderTag> findConfByIdList(List<Integer> idList) {
        return confOrderTagDao.selectByIdList(idList);
    }

    @Override
    public void updateConfById(ConfOrderTag conf) {
        Objects.requireNonNull(conf.getId(), "ID不能为空");

        conf.setUpdateTime(DateUtil.getNow());
        confOrderTagDao.updateByPrimaryKeySelective(conf);
    }

    @Override
    public Integer insertConf(ConfOrderTag conf) {
        conf.setCreateTime(DateUtil.getNow());
        return confOrderTagDao.insertSelective(conf);
    }

}
